export default {
	// 获取用户信息
	getUserAbout() {
		let json = {}
		return new Promise((resolve, reject) => {
			uni.getUserProfile({
				desc: '获取用户信息',
				lang: 'zh_CN',
				success: res=>{
					json = res.userInfo
					resolve()
				},
				fail: err=>{
					reject(err)
				}
			})
		}).then((e) => {
			return new Promise((resolve, reject) => {
				uni.login({
					provider: 'weixin',
					success: wxopenid=> {
						resolve({wxopenid:wxopenid,info:json})
					},
					fail: err=>{
						reject(err)
					}
				})
			})
		}).catch(err => {
			// console.log(err,'err_catch22')
			uni.showToast({title:"微信登录授权失败",icon:"none"});
		})
	},
	getUserAboutApp() {
		return new Promise((resolve, reject) => {
			uni.login({
				provider: 'weixin',
				success: loginRes=> {
					resolve(loginRes)
				},
				fail: err=>{
					console.log(err,'err')
					reject(err)
				}
			})
		}).then((e) => {
			return new Promise((resolve, reject) => {
				uni.getUserInfo({
				  provider: 'weixin',
				  success: (infoRes)=> {
					resolve({wxopenid:e,info:infoRes.userInfo})
				  },
				  fail: err=>{
				  	reject(err)
				  }
				})
			})
		}).catch(err => {
			uni.showToast({title:"微信登录授权失败",icon:"none"});
		})
	}
}
